'use strict';
/**
 * @ngdoc directive
 * @name jgappApp.directive:relativeModule
 * @description
 * # relativeModule
 */
angular.module('jgappApp')
  .directive('relativeModule', function ($location, RelativeModule, localStorageService, Modulemap, Util, $timeout) {
    return {
      restrict: 'AE',
      replace: true,
      link: function postLink(scope, element, attrs) {
        var param = {};
        $timeout(function () {
          if (attrs.moduleNo) {
            element[0].classList.add("c-blue")
          }
        }, 200)
        element.bind('click', function () {
          param.moduleNo = attrs.moduleNo
          param.formKey = RelativeModule[attrs.relativeModule] || attrs.relativeModule
          param.formKey = param.formKey.split("#")[0];
          var moduleName = Modulemap.getViewNameAndIcon(param.formKey)
          if (!moduleName || (param.moduleNo == "无" || param.moduleNo === "")) {
            Util.Toast("移动端不支持该明细的查看或没有明细")
            return
          }
          var url = "relativePage/" + moduleName.checkViewName + "/" + param.formKey + "/" + param.moduleNo;
          Util.setOriginPath(
            url,
            param.formKey,
            Util.CHECK
          );
          $location.path(url)
          scope.$apply()
        });
      }
    };
  });
